<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var date = new Date(); //当前时间
			// date = new Date('2038-08-08 18:18:18');//指定时间
			// console.log(date);

			var year = date.getFullYear();
			var month = date.getMonth() + 1; //从0开始
			var day = date.getDate();
			var hour = date.getHours();
			var min = date.getMinutes();
			var sec = date.getSeconds();
			// console.log(year + "年", month + "月", day + "日", hour + "时", min + "分", sec + "秒");

			var t = date.getTime();
			// console.log(t);

			//2022-8-9和2008-8-8相差多少天

			var endTime = Date.now(); //静态方法(毫秒数)

			var startTime = new Date('2008-8-8');
			startTime = startTime.getTime();

			var es = endTime - startTime;

			var dt = es / 1000 / 60 / 60 / 24;
			
			console.log(dt);
		</script>
	</body>
</html>
